package com.renli.shiro.factory;

import com.renli.shiro.filter.MyFormAuthenticationFilter;
import org.springframework.beans.factory.annotation.Autowired;

import javax.servlet.Filter;
import java.util.LinkedHashMap;

public class FilterChainDefinitionMapBuilder {

    @Autowired
    private MyFormAuthenticationFilter myFormAuthenticationFilter;


    public LinkedHashMap<String,String> buildFilterChainDefinitionMap(){

        LinkedHashMap<String,String> map = new LinkedHashMap<>();
         /*  /login.jsp = anon
                /login = anon
                /reg = anon
                /myshiro/logout = logout
                /user/list = roles[user]
                /admin/list = roles[admin]
                /index.jsp = rememberAuthFilter

                -/** = authc  */
/*
        <mvc:exclude-mapping path="/swagger-ui.html/**"/>
            <mvc:exclude-mapping path="/swagger-resources/**"/>
            <mvc:exclude-mapping path="/webjars/**"/>
            <mvc:exclude-mapping path="/v2/**"/>

 * */
        map.put("/system/logout", "logout");

//        map.put("/login.jsp", "anon");
//        map.put("/login","anon");
//        map.put("/loginToken","anon");
//        map.put("/reg", "anon");
////        swagger
//        map.put("/swagger-ui.html/**","anon");
//        map.put("/swagger-resources/**","anon");
//        map.put("/webjars/**","anon");
//        map.put("/v2/**", "anon");
//        //
//
//        map.put("/user/list", "roles[user]");
//        map.put("/admin/list", "roles[admin]");
//        map.put("/index.jsp","myFilter");
//        map.put("/**", "authc");
        return map;
    }

    public LinkedHashMap<String, Filter> setFilters(){
        LinkedHashMap<String, Filter> filterMap=new LinkedHashMap<>();
        filterMap.put("myFilter",myFormAuthenticationFilter);
        return filterMap;
    }
}
